package com.zenchn.dynamic;

import static com.zenchn.dynamic.TMiCustomerDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TMiCustomer;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TMiCustomerDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    BasicColumn[] selectList = BasicColumn.columnList(customerId, customerType, areasCode, customerName, customerAdress, business, region, net, level, accountId, belongTo, creator, createTime, reviser, modifyTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TMiCustomer> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TMiCustomer> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TMiCustomerResult")
    Optional<TMiCustomer> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TMiCustomerResult", value = {
        @Result(column="customer_id", property="customerId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="customer_type", property="customerType", jdbcType=JdbcType.CHAR),
        @Result(column="areas_code", property="areasCode", jdbcType=JdbcType.CHAR),
        @Result(column="customer_name", property="customerName", jdbcType=JdbcType.VARCHAR),
        @Result(column="customer_adress", property="customerAdress", jdbcType=JdbcType.VARCHAR),
        @Result(column="business", property="business", jdbcType=JdbcType.VARCHAR),
        @Result(column="region", property="region", jdbcType=JdbcType.VARCHAR),
        @Result(column="net", property="net", jdbcType=JdbcType.VARCHAR),
        @Result(column="level", property="level", jdbcType=JdbcType.INTEGER),
        @Result(column="account_id", property="accountId", jdbcType=JdbcType.CHAR),
        @Result(column="belong_to", property="belongTo", jdbcType=JdbcType.CHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.CHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="reviser", property="reviser", jdbcType=JdbcType.CHAR),
        @Result(column="modify_time", property="modifyTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TMiCustomer> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TMiCustomer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TMiCustomer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int deleteByPrimaryKey(String customerId_) {
        return delete(c -> 
            c.where(customerId, isEqualTo(customerId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int insert(TMiCustomer record) {
        return MyBatis3Utils.insert(this::insert, record, TMiCustomer, c ->
            c.map(customerId).toProperty("customerId")
            .map(customerType).toProperty("customerType")
            .map(areasCode).toProperty("areasCode")
            .map(customerName).toProperty("customerName")
            .map(customerAdress).toProperty("customerAdress")
            .map(business).toProperty("business")
            .map(region).toProperty("region")
            .map(net).toProperty("net")
            .map(level).toProperty("level")
            .map(accountId).toProperty("accountId")
            .map(belongTo).toProperty("belongTo")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
            .map(reviser).toProperty("reviser")
            .map(modifyTime).toProperty("modifyTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int insertMultiple(Collection<TMiCustomer> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TMiCustomer, c ->
            c.map(customerId).toProperty("customerId")
            .map(customerType).toProperty("customerType")
            .map(areasCode).toProperty("areasCode")
            .map(customerName).toProperty("customerName")
            .map(customerAdress).toProperty("customerAdress")
            .map(business).toProperty("business")
            .map(region).toProperty("region")
            .map(net).toProperty("net")
            .map(level).toProperty("level")
            .map(accountId).toProperty("accountId")
            .map(belongTo).toProperty("belongTo")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
            .map(reviser).toProperty("reviser")
            .map(modifyTime).toProperty("modifyTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int insertSelective(TMiCustomer record) {
        return MyBatis3Utils.insert(this::insert, record, TMiCustomer, c ->
            c.map(customerId).toPropertyWhenPresent("customerId", record::getCustomerId)
            .map(customerType).toPropertyWhenPresent("customerType", record::getCustomerType)
            .map(areasCode).toPropertyWhenPresent("areasCode", record::getAreasCode)
            .map(customerName).toPropertyWhenPresent("customerName", record::getCustomerName)
            .map(customerAdress).toPropertyWhenPresent("customerAdress", record::getCustomerAdress)
            .map(business).toPropertyWhenPresent("business", record::getBusiness)
            .map(region).toPropertyWhenPresent("region", record::getRegion)
            .map(net).toPropertyWhenPresent("net", record::getNet)
            .map(level).toPropertyWhenPresent("level", record::getLevel)
            .map(accountId).toPropertyWhenPresent("accountId", record::getAccountId)
            .map(belongTo).toPropertyWhenPresent("belongTo", record::getBelongTo)
            .map(creator).toPropertyWhenPresent("creator", record::getCreator)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(reviser).toPropertyWhenPresent("reviser", record::getReviser)
            .map(modifyTime).toPropertyWhenPresent("modifyTime", record::getModifyTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default Optional<TMiCustomer> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TMiCustomer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default List<TMiCustomer> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TMiCustomer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default List<TMiCustomer> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TMiCustomer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default Optional<TMiCustomer> selectByPrimaryKey(String customerId_) {
        return selectOne(c ->
            c.where(customerId, isEqualTo(customerId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TMiCustomer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    static UpdateDSL<UpdateModel> updateAllColumns(TMiCustomer record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(customerId).equalTo(record::getCustomerId)
                .set(customerType).equalTo(record::getCustomerType)
                .set(areasCode).equalTo(record::getAreasCode)
                .set(customerName).equalTo(record::getCustomerName)
                .set(customerAdress).equalTo(record::getCustomerAdress)
                .set(business).equalTo(record::getBusiness)
                .set(region).equalTo(record::getRegion)
                .set(net).equalTo(record::getNet)
                .set(level).equalTo(record::getLevel)
                .set(accountId).equalTo(record::getAccountId)
                .set(belongTo).equalTo(record::getBelongTo)
                .set(creator).equalTo(record::getCreator)
                .set(createTime).equalTo(record::getCreateTime)
                .set(reviser).equalTo(record::getReviser)
                .set(modifyTime).equalTo(record::getModifyTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TMiCustomer record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(customerId).equalToWhenPresent(record::getCustomerId)
                .set(customerType).equalToWhenPresent(record::getCustomerType)
                .set(areasCode).equalToWhenPresent(record::getAreasCode)
                .set(customerName).equalToWhenPresent(record::getCustomerName)
                .set(customerAdress).equalToWhenPresent(record::getCustomerAdress)
                .set(business).equalToWhenPresent(record::getBusiness)
                .set(region).equalToWhenPresent(record::getRegion)
                .set(net).equalToWhenPresent(record::getNet)
                .set(level).equalToWhenPresent(record::getLevel)
                .set(accountId).equalToWhenPresent(record::getAccountId)
                .set(belongTo).equalToWhenPresent(record::getBelongTo)
                .set(creator).equalToWhenPresent(record::getCreator)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(reviser).equalToWhenPresent(record::getReviser)
                .set(modifyTime).equalToWhenPresent(record::getModifyTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int updateByPrimaryKey(TMiCustomer record) {
        return update(c ->
            c.set(customerType).equalTo(record::getCustomerType)
            .set(areasCode).equalTo(record::getAreasCode)
            .set(customerName).equalTo(record::getCustomerName)
            .set(customerAdress).equalTo(record::getCustomerAdress)
            .set(business).equalTo(record::getBusiness)
            .set(region).equalTo(record::getRegion)
            .set(net).equalTo(record::getNet)
            .set(level).equalTo(record::getLevel)
            .set(accountId).equalTo(record::getAccountId)
            .set(belongTo).equalTo(record::getBelongTo)
            .set(creator).equalTo(record::getCreator)
            .set(createTime).equalTo(record::getCreateTime)
            .set(reviser).equalTo(record::getReviser)
            .set(modifyTime).equalTo(record::getModifyTime)
            .where(customerId, isEqualTo(record::getCustomerId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer")
    default int updateByPrimaryKeySelective(TMiCustomer record) {
        return update(c ->
            c.set(customerType).equalToWhenPresent(record::getCustomerType)
            .set(areasCode).equalToWhenPresent(record::getAreasCode)
            .set(customerName).equalToWhenPresent(record::getCustomerName)
            .set(customerAdress).equalToWhenPresent(record::getCustomerAdress)
            .set(business).equalToWhenPresent(record::getBusiness)
            .set(region).equalToWhenPresent(record::getRegion)
            .set(net).equalToWhenPresent(record::getNet)
            .set(level).equalToWhenPresent(record::getLevel)
            .set(accountId).equalToWhenPresent(record::getAccountId)
            .set(belongTo).equalToWhenPresent(record::getBelongTo)
            .set(creator).equalToWhenPresent(record::getCreator)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(reviser).equalToWhenPresent(record::getReviser)
            .set(modifyTime).equalToWhenPresent(record::getModifyTime)
            .where(customerId, isEqualTo(record::getCustomerId))
        );
    }
}